package com.addplus.townmall.server.api.mapper.town;

import com.addplus.townmall.server.api.model.town.ShopRelation;
import com.addplus.townmall.server.api.model.town.expand.ShopProductRelationExpand;
import com.addplus.townmall.server.api.utils.BaseAddMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商品推荐商品关联表 Mapper 接口
 * </p>
 *
 * @author zhangjiehang
 * @since 2018-08-27
 */
public interface ShopRelationMapper extends BaseAddMapper<ShopRelation> {

    @Select("<script>" +
            "SELECT\n" +
            " sp.id AS id,\n" +
            " sp.shop_code AS shopCode,\n" +
            " sp.shop_name AS shopName,\n" +
            " sp.shop_seal_img AS shopSealImg,\n" +
            " sp.sale_price AS salePrice,\n" +
            " sp.line_price AS linePrice,\n" +
            " sp.store_id AS storeId,\n" +
            " s.store_name AS storeName\n" +
            "FROM\n" +
            " <if test='shopProductType==1'>\n" +
            " shop_product sp" +
            " </if>" +
            " <if test='shopProductType==2'>\n" +
            " shop_product_fight sp" +
            " </if>" +
            " LEFT JOIN store s ON s.id = sp.store_id\n" +
            "WHERE\n" +
            " sp.is_deleted = 0 \n" +
            " AND sp.sale_status = 0 \n" +
            " AND s.is_delete = 0 \n" +
            " AND sp.id in (#{relationShopPath})" +
            "</script>")
    List<ShopProductRelationExpand> getShopProductRelation(@Param("relationShopPath") String relationShopPath, @Param("shopProductType") Integer shopProductType);

}
